cmake_minimum_required(VERSION 2.8)

project( examples )

find_package( OpenCV REQUIRED )
find_package( OpenGL )

if(OPENGL_FOUND)
  include_directories( ${OpenCV_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS} )
else()
  include_directories( ${OpenCV_INCLUDE_DIRS} )
endif()

#########################
# FOR LEARNING OPENCV 3 #
#########################

###############
### COMPILE ###
###############

# COMPILE EXAMPLES
add_executable( example_02-01 example_02-01.cpp )
add_executable( example_02-02 example_02-02.cpp )
add_executable( example_02-03 example_02-03.cpp )
add_executable( example_02-04 example_02-04.cpp )
add_executable( example_02-05 example_02-05.cpp )
add_executable( example_02-06 example_02-06.cpp )
add_executable( example_02-07 example_02-07.cpp )
add_executable( example_02-08 example_02-08.cpp )
add_executable( example_02-09 example_02-09.cpp )
add_executable( example_02-10 example_02-10.cpp )
add_executable( example_02-11 example_02-11.cpp )
add_executable( example_04-01 example_04-01.cpp )
add_executable( example_04-02 example_04-02.cpp )
add_executable( example_04-03 example_04-03.cpp )
add_executable( example_04-04 example_04-04.cpp )
add_executable( example_05-01 example_05-01.cpp )
add_executable( example_07-01 example_07-01.cpp )
add_executable( example_08-01 example_08-01.cpp )
add_executable( example_08-02 example_08-02.cpp )
add_executable( example_08-03 example_08-03.cpp )
add_executable( example_09-01 example_09-01.cpp )
add_executable( example_09-02 example_09-02.cpp )
add_executable( example_09-03 example_09-03.cpp )
if(OPENGL_FOUND)
  add_executable( example_09-04 example_09-04.cpp )
endif()
# Can only build if you have Qt installed add_executable( example_09-05 example_09-05.cpp )
add_executable( example_10-01 example_10-01.cpp )
add_executable( example_10-02 example_10-02.cpp )
add_executable( example_10-03 example_10-03.cpp )
add_executable( example_11-01 example_11-01.cpp )
add_executable( example_11-02 example_11-02.cpp )
add_executable( example_11-03 example_11-03.cpp )
add_executable( example_12-01 example_12-01.cpp )
add_executable( example_12-02 example_12-02.cpp )
add_executable( example_12-03 example_12-03.cpp )
add_executable( example_12-04 example_12-04.cpp )
add_executable( example_13-01 example_13-01.cpp )
add_executable( example_13-02 example_13-02.cpp )
add_executable( example_13-03 example_13-03.cpp )
add_executable( example_14-01 example_14-01.cpp )
add_executable( example_14-02 example_14-02.cpp )
add_executable( example_14-03 example_14-03.cpp )
add_executable( example_14-04 example_14-04.cpp )
add_executable( example_15-01 example_15-01.cpp )
add_executable( example_15-02 example_15-02.cpp )
add_executable( example_15-03 example_15-03.cpp )
add_executable( example_15-04 example_15-04.cpp )
add_executable( example_15-05 example_15-05.cpp )
add_executable( example_15-BackgroundSubtractor example_15-BackgroundSubtractor.cpp )
add_executable( example_16-01 example_16-01.cpp )
add_executable( example_16-02 example_16-02.cpp )
add_executable( example_17-01 example_17-01.cpp )
add_executable( example_17-02 example_17-02.cpp )
add_executable( example_18-01 example_18-01.cpp )
add_executable( example_18-01_from_disk example_18-01_from_disk.cpp )
add_executable( example_19-01 example_19-01.cpp )
add_executable( example_19-02 example_19-02.cpp )
add_executable( example_19-03 example_19-03.cpp )
add_executable( example_19-04 example_19-04.cpp )
add_executable( example_20-01 example_20-01.cpp )
add_executable( example_20-02 example_20-02.cpp )
add_executable( example_21-01 example_21-01.cpp )
add_executable( example_22-01 example_22-01.cpp )

# NOW COMPILE SOME ANSWERS TO EXERCISES:
add_executable( Exercises_5   Exercises_5.cpp   )
add_executable( Exercises_7 Exercises_7.cpp )
add_executable( Exercises_8_1 Exercises_8_1.cpp )
add_executable( Exercises_9_1-2-10-11-12-15-16 Exercises_9_1-2-10-11-12-15-16.cpp )
add_executable( Exercises_9_4 Exercises_9_4.cpp ) 
add_executable( Exercises_9_5 Exercises_9_5.cpp )
add_executable( Exercises_11-1-2-5-6-7 Exercises_11-1-2-5-6-7.cpp )

################
###   LINK   ###
################
# FIRST LINK EXAMPLES:
target_link_libraries( example_02-01 ${OpenCV_LIBS} )
target_link_libraries( example_02-02 ${OpenCV_LIBS} )
target_link_libraries( example_02-03 ${OpenCV_LIBS} )
target_link_libraries( example_02-04 ${OpenCV_LIBS} )
target_link_libraries( example_02-05 ${OpenCV_LIBS} )
target_link_libraries( example_02-06 ${OpenCV_LIBS} )
target_link_libraries( example_02-07 ${OpenCV_LIBS} )
target_link_libraries( example_02-08 ${OpenCV_LIBS} )
target_link_libraries( example_02-09 ${OpenCV_LIBS} )
target_link_libraries( example_02-10 ${OpenCV_LIBS} )
target_link_libraries( example_02-11 ${OpenCV_LIBS} )
target_link_libraries( example_04-01 ${OpenCV_LIBS} )
target_link_libraries( example_04-02 ${OpenCV_LIBS} )
target_link_libraries( example_04-03 ${OpenCV_LIBS} )
target_link_libraries( example_04-04 ${OpenCV_LIBS} )
target_link_libraries( example_05-01 ${OpenCV_LIBS} )
target_link_libraries( example_07-01 ${OpenCV_LIBS} )
target_link_libraries( example_08-01 ${OpenCV_LIBS} )
target_link_libraries( example_08-02 ${OpenCV_LIBS} )
target_link_libraries( example_08-03 ${OpenCV_LIBS} )
target_link_libraries( example_09-01 ${OpenCV_LIBS} )
target_link_libraries( example_09-02 ${OpenCV_LIBS} )
target_link_libraries( example_09-03 ${OpenCV_LIBS} )
target_link_libraries( example_09-02 ${OpenCV_LIBS} )
target_link_libraries( example_09-03 ${OpenCV_LIBS} )
if(OPENGL_FOUND)
  target_link_libraries( example_09-04 ${OpenCV_LIBS} ${OPENGL_LIBRARIES} )
endif()
# Need Qt target_link_libraries( example_09-05 ${OpenCV_LIBS} )
target_link_libraries( example_10-01 ${OpenCV_LIBS} )
target_link_libraries( example_10-02 ${OpenCV_LIBS} )
target_link_libraries( example_10-03 ${OpenCV_LIBS} )
target_link_libraries( example_11-01 ${OpenCV_LIBS} )
target_link_libraries( example_11-02 ${OpenCV_LIBS} )
target_link_libraries( example_11-03 ${OpenCV_LIBS} )
target_link_libraries( example_12-01 ${OpenCV_LIBS} )
target_link_libraries( example_12-02 ${OpenCV_LIBS} )
target_link_libraries( example_12-03 ${OpenCV_LIBS} )
target_link_libraries( example_12-04 ${OpenCV_LIBS} )
target_link_libraries( example_13-01 ${OpenCV_LIBS} )
target_link_libraries( example_13-02 ${OpenCV_LIBS} )
target_link_libraries( example_13-03 ${OpenCV_LIBS} )
target_link_libraries( example_14-01 ${OpenCV_LIBS} )
target_link_libraries( example_14-02 ${OpenCV_LIBS} )
target_link_libraries( example_14-03 ${OpenCV_LIBS} )
target_link_libraries( example_14-04 ${OpenCV_LIBS} )
target_link_libraries( example_15-01 ${OpenCV_LIBS} )
target_link_libraries( example_15-02 ${OpenCV_LIBS} )
target_link_libraries( example_15-03 ${OpenCV_LIBS} )
target_link_libraries( example_15-04 ${OpenCV_LIBS} )
target_link_libraries( example_15-05 ${OpenCV_LIBS} )
target_link_libraries( example_15-BackgroundSubtractor ${OpenCV_LIBS} )
target_link_libraries( example_16-01 ${OpenCV_LIBS} )
target_link_libraries( example_16-02 ${OpenCV_LIBS} )
target_link_libraries( example_17-01 ${OpenCV_LIBS} )
target_link_libraries( example_17-02 ${OpenCV_LIBS} )
target_link_libraries( example_18-01 ${OpenCV_LIBS} )
target_link_libraries( example_18-01_from_disk ${OpenCV_LIBS} )
target_link_libraries( example_19-01 ${OpenCV_LIBS} )
target_link_libraries( example_19-02 ${OpenCV_LIBS} )
target_link_libraries( example_19-03 ${OpenCV_LIBS} )
target_link_libraries( example_19-04 ${OpenCV_LIBS} )
target_link_libraries( example_20-01 ${OpenCV_LIBS} )
target_link_libraries( example_20-02 ${OpenCV_LIBS} )
target_link_libraries( example_21-01 ${OpenCV_LIBS} )
target_link_libraries( example_22-01 ${OpenCV_LIBS} )

# NOW LINK EXERCISES 
target_link_libraries( Exercises_5 ${OpenCV_LIBS} )
target_link_libraries( Exercises_7 ${OpenCV_LIBS} )
target_link_libraries( Exercises_8_1 ${OpenCV_LIBS} )
target_link_libraries( Exercises_9_1-2-10-11-12-15-16 ${OpenCV_LIBS} )
target_link_libraries( Exercises_9_4 ${OpenCV_LIBS} )
target_link_libraries( Exercises_9_5 ${OpenCV_LIBS} )
target_link_libraries( Exercises_11-1-2-5-6-7 ${OpenCV_LIBS} )
